class SearchFriend extends Scene{
    private searchArr:any  = [];
    private searchList:eui.List;
    private needUp: boolean = false;
    private searchGroup:eui.Group;
    private searchScroller:eui.Scroller;
    private searchReturnImage:eui.Image;
    
    public constructor() {
        super();
        this.addEventListener(egret.Event.COMPLETE, this.addToStage, this);
      }
    
      public onSkinLoaded() {
        this.searchReturnImage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btnHandler, this);
      }

      private btnHandler(evt: egret.TouchEvent) {
        let btnFocused = evt.currentTarget;        
		    switch (btnFocused) {
          case this.searchReturnImage:
              SceneManager.instance.removeScene(this);
              break;
        }

        }

      private addToStage():void{
        for(var i:number=1;i<=10;i++){
          this.searchArr.push({name:"南华大学好友"});
        }
        this.searchList.dataProvider=new eui.ArrayCollection(this.searchArr);
        this.searchList.itemRenderer=SearchFriendRenderer;
        this.searchScroller.addEventListener(eui.UIEvent.CHANGE, this.moveHandler, this);
		    this.searchScroller.addEventListener(eui.UIEvent.CHANGE_END, this.outHandler, this);
      }

      private moveHandler(evt: eui.UIEvent): void {
        //检测是否超过滚动底部
        // console.log(this.moveScroll.viewport.scrollV);
        // console.log(this.moveScroll.viewport.contentHeight - this.moveScroll.viewport.height);
        console.log(this.searchScroller.viewport.scrollV > this.searchScroller.viewport.contentHeight - this.searchScroller.viewport.height);
        if(this.searchScroller.viewport.scrollV > (this.searchScroller.viewport.contentHeight - this.searchScroller.viewport.height)+40){
          this.needUp = true;
         }
      }
      private outHandler(evt:eui.UIEvent):void{
        //停止滚动时判断needUp是否为true;
        if(this.needUp){
          this.needUp = false;
          this.addToStage();
        }
      }
}